package com.peng.controller;

import com.peng.pojo.Dept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RestController
public class ConsumerController {
    @Autowired
    private RestTemplate template;
    //private static final String HTTP_PRO="http://localhost:8801";
    private static final String HTTP_PRO="http://springcloud-provider-dept";

    @RequestMapping("/con/add")
    public boolean add(Dept dept){
        return template.postForObject(HTTP_PRO+"/dept/add",dept,Boolean.class);
    }
    @RequestMapping("/con/id/{id}")
    public Dept queryId(@PathVariable("id") long id){
        return template.getForObject(HTTP_PRO+"/dept/id/"+id,Dept.class);
    }
    @RequestMapping("/con/all")
    public List<Dept> queryAll(){
        return template.getForObject(HTTP_PRO+"/dept/all",List.class);
    }




}
